﻿@model SCMS.UI.Areas.Admin.Models.SystemUser.SystemUserModel
@using SCMS.CoreBusinessLogic.Settings

@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)
<table width="98%" align="center" border="0" cellpadding="2" cellspacing="2" style=" border-bottom: 1px solid Grey;">
    <tr class="gridheader2">
        <td width="33%">First Name</td>
        <td width="34%">Last Name</td>
        <td width="33%">Email Address</td>
    </tr>
    <tr>
        <td width="33%">
            @Html.TextBoxFor(model => model.FirstName)<br />
            @Html.ValidationMessageFor(model => model.FirstName)
        </td>
        <td width="34%">
            @Html.EditorFor(model => model.OtherNames)<br />
            @Html.ValidationMessageFor(model => model.OtherNames)
        </td>
        <td width="33%">
            @Html.EditorFor(model => model.Email)<br />
            @Html.ValidationMessageFor(model => model.Email)
        </td>
    </tr>
    <tr class="gridheader2">
        <td width="33%">Account Status</td>
        <td width="34%">Password</td>
        <td width="33%">Confirm Password</td>
    </tr>
    <tr>
        <td width="33%" align="center">
            @Html.EditorFor(model => model.Active) Active 
            @Html.Raw("&nbsp;")
            @Html.EditorFor(model => model.Locked) Locked <br />

        </td>
        <td width="34%">
            @Html.PasswordFor(model => model.Password)<br />
            @Html.ValidationMessageFor(model => model.Password)
        </td>
        <td width="33%">
            @Html.PasswordFor(model => model.ConfirmPassword)<br />
            @Html.ValidationMessageFor(model => model.ConfirmPassword)
        </td>
    </tr>
    <tr class="gridheader2">
        <td width="33%">ID Number</td>
        <td width="34%">Finance Limit</td>
        <td width="33%">Available</td>
    </tr>
    <tr>
        <td width="33%">
            @Html.EditorFor(model => model.IdNumber)<br />
            @Html.ValidationMessageFor(model => model.IdNumber)
        </td>
        <td width="34%">
            @Html.DropDownListFor(model => model.FinanceLimitId, Model.FinanceLimits, "--Please Select--")
        </td>
        <td width="33%">
            @Html.CheckBoxFor(model => model.Available)
        </td>
    </tr>
    <tr class="gridheader2">
        <td width="33%">Designation</td>
        <td width="34%">Country Sub Office</td>
        <td width="33%">Phone Number</td>
    </tr>
    <tr>
        <td width="33%">
            @Html.DropDownListFor(model => model.SelectedDesignationId, Model.AvailableDesignation)<br />
            @Html.ValidationMessageFor(model => model.SelectedDesignationId)
        </td>
        <td width="34%">
            @Html.DropDownListFor(model => model.SelectedCountrySubOfficeId, Model.AvailableCountrySubOffices)<br />
            @Html.ValidationMessageFor(model => model.SelectedCountrySubOfficeId)
        </td>
        <td width="33%">
            @Html.EditorFor(model => model.OfficialPhone)<br />
            @Html.ValidationMessageFor(model => model.OfficialPhone)
        </td>
    </tr>
    <tr class="gridheader2">
        <td width="33%">Role(s)</td>
        <td width="34%">Photo</td>
        <td width="33%">Signature</td>
    </tr>
    <tr>
        <td>
            @if (UserContext.HasPermission(StandardPermissionProvider.RolesManage))
            {
                 foreach (var role in Model.AvailableRoles)
                 {
                    <input name="@Html.FieldNameFor(model => model.SelectedRoleIds)" type="checkbox" value="@role.Value" @(role.Selected ? "checked=\"checked\"" : "") /> @role.Text <br />            
                 }
            }
        </td>
        <td valign="top" align="center">
            @if (Model.PhotoLocation.IsNotNullOrWhiteSpace())
            {
                <img src="@Url.Content(Model.PhotoLocation)" width="150" alt="" />
                <br />
            }
            
            <input type="file" name="@Html.FieldNameFor(model => model.PhotoLocationUpload)" /><br />
            Max. size: @(SettingsHelper<CommonSettings>.Settings.PersonPhotoMaxSize) KB (@(SettingsHelper<CommonSettings>.Settings.AllowedImageExtensions.StringJoin("", ",")))<br />
            @Html.ValidationMessageFor(model => model.PhotoLocationUpload)
        </td>
        <td valign="top" align="center">
            @if (Model.PersonSignatureImageId != null)
            {
                <img src="@Url.Action("Photo", "Person", new { id = Model.PersonSignatureImageId, area = "" })" alt="" />
                <br />
            }
            <input type="file" name="@Html.FieldNameFor(model => model.SignatureImageUpload)" /><br />
            Max. size: @(SettingsHelper<CommonSettings>.Settings.SignaturePhotoMaxSize) KB (@(SettingsHelper<CommonSettings>.Settings.AllowedImageExtensions.StringJoin("", ",")))<br />
            @Html.ValidationMessageFor(model => model.SignatureImageUpload)<br />
                    
        </td>
    </tr>
</table>
<br />
<table width="98%" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td width="50%">
            @if (Model.Id.IsNotEmpty())
            {
                <table>
                    <tr>
                        <td><b>Last Ip Address:</b></td>
                        <td>@Html.DisplayFor(model => model.LastIpAddress)</td>
                    </tr>
                    <tr>
                        <td><b>Last Login Date:</b></td>
                        <td>@Model.LastLoginDate.FormatLongDatePatternWithTime()</td>
                    </tr>
                    <tr>
                        <td><b>Failed Login Attempts:</b></td>
                        <td>@Html.DisplayFor(model => model.UserLoginCount)</td>
                    </tr>
                    <tr>
                        <td><b>Date Created:</b></td>
                        <td>@Model.Created.FormatLongDatePatternWithTime()</td>
                    </tr>
                    <tr>
                        <td><b>Last Modified:</b></td>
                        <td>@Model.Modified.FormatLongDatePatternWithTime()</td>
                    </tr>
                    <tr>
                        <td>
                            @Html.ActionLink("Back to List", "Index")
                        </td>
                        <td></td>
                    </tr>
                </table>
            }
        </td>
        <td width="50%" align="right" valign="top">
            <input type="submit" class="btn green" value="Save" /> 
        </td>
    </tr>
</table>